<?
set_time_limit(9999999);
/***************************************************************************

*                            Dolphin Smart Community Builder

*                              -----------------

*     begin                : Mon Mar 23 2006

*     copyright            : (C) 2006 BoonEx Group

*     website              : http://www.boonex.com/

* This file is part of Dolphin - Smart Community Builder

*

* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License. 

* http://creativecommons.org/licenses/by/3.0/

*

* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;

* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

* See the Creative Commons Attribution 3.0 License for more details. 

* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin, 

* see license.txt file; if not, write to marketing@boonex.com

***************************************************************************/
 
require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'languages.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );

echo "START .....<br /><br />";

echo "UPDATING DATABASE .....<br /><br />";
 
db_res("UPDATE `sys_modules` SET `version`='2.0.1' WHERE `uri` = 'location' AND `db_prefix` = 'modzzz_location_'");

db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_service_main` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `location_id` int(11) NOT NULL,
  `title` varchar(100) NOT NULL default '',
  `uri` varchar(255) NOT NULL,
  `desc` text NOT NULL,
  `status` enum('approved','pending') NOT NULL default 'approved',
  `country` varchar(2) NOT NULL default 'US',
  `city` varchar(50) NOT NULL default '', 
  `address1` varchar(100) NOT NULL default '',
  `address2` varchar(100) NOT NULL default '',
  `zip` varchar(30) NOT NULL default '',   
  `located` varchar(100) NOT NULL default '', 
  `phone` varchar(100) NOT NULL default '',  
  `website` varchar(100) NOT NULL default '',  
  `thumb` int(11) NOT NULL,
  `video_embed` TEXT NOT NULL, 
  `photo` int(11) NOT NULL,   
  `created` int(11) NOT NULL, 
  `author_id` int(10) unsigned NOT NULL default '0',
  `tags` varchar(255) NOT NULL default '',
  `categories` text NOT NULL,
  `views` int(11) NOT NULL,
  `rate` float NOT NULL,
  `rate_count` int(11) NOT NULL,
  `fans_count` int(11) NOT NULL,
  `comments_count` int(11) NOT NULL,
  `featured` tinyint(4) NOT NULL,
  `allow_view_to` int(11) NOT NULL,
  `allow_view_participants_to` varchar(16) NOT NULL,
  `allow_comment_to` varchar(16) NOT NULL,
  `allow_rate_to` varchar(16) NOT NULL,
  `allow_join_to` int(11) NOT NULL,
  `allow_post_in_forum_to` varchar(16) NOT NULL,
  `join_confirmation` tinyint(4) NOT NULL default '0',
  `allow_upload_photos_to` varchar(16) NOT NULL,
  `allow_upload_videos_to` varchar(16) NOT NULL,
  `allow_upload_sounds_to` varchar(16) NOT NULL,
  `allow_upload_files_to` varchar(16) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `loc_service_uri` (`uri`),
  KEY `loc_service_author_id` (`author_id`),
  KEY `loc_service_created` (`created`),
  FULLTEXT KEY `loc_service_title` (`title`,`desc`,`city`,`tags`,`categories`),
  FULLTEXT KEY `loc_service_tags` (`tags`),
  FULLTEXT KEY `loc_service_categories` (`categories`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
");
  
db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_service_images` (
  `entry_id` int(10) unsigned NOT NULL,
  `media_id` int(10) unsigned NOT NULL,
  UNIQUE KEY `entry_id` (`entry_id`,`media_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
  
db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_service_videos` (
  `entry_id` int(10) unsigned NOT NULL,
  `media_id` int(11) NOT NULL,
  UNIQUE KEY `entry_id` (`entry_id`,`media_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
  
db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_service_sounds` (
  `entry_id` int(10) unsigned NOT NULL,
  `media_id` int(11) NOT NULL,
  UNIQUE KEY `entry_id` (`entry_id`,`media_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
  
db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_service_files` (
  `entry_id` int(10) unsigned NOT NULL,
  `media_id` int(11) NOT NULL,
  UNIQUE KEY `entry_id` (`entry_id`,`media_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
  
db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_service_rating` (
  `gal_id` smallint( 6 ) NOT NULL default '0',
  `gal_rating_count` int( 11 ) NOT NULL default '0',
  `gal_rating_sum` int( 11 ) NOT NULL default '0',
  UNIQUE KEY `gal_id` (`gal_id`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
");
  
db_res(" 
CREATE TABLE IF NOT EXISTS `modzzz_location_service_rating_track` (
  `gal_id` smallint( 6 ) NOT NULL default '0',
  `gal_ip` varchar( 20 ) default NULL,
  `gal_date` datetime default NULL,
  KEY `gal_ip` (`gal_ip`, `gal_id`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
");
  
db_res(" 
CREATE TABLE IF NOT EXISTS `modzzz_location_service_cmts` (
  `cmt_id` int( 11 ) NOT NULL AUTO_INCREMENT ,
  `cmt_parent_id` int( 11 ) NOT NULL default '0',
  `cmt_object_id` int( 12 ) NOT NULL default '0',
  `cmt_author_id` int( 10 ) unsigned NOT NULL default '0',
  `cmt_text` text NOT NULL ,
  `cmt_mood` tinyint( 4 ) NOT NULL default '0',
  `cmt_rate` int( 11 ) NOT NULL default '0',
  `cmt_rate_count` int( 11 ) NOT NULL default '0',
  `cmt_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `cmt_replies` int( 11 ) NOT NULL default '0',
  PRIMARY KEY ( `cmt_id` ),
  KEY `cmt_object_id` (`cmt_object_id` , `cmt_parent_id`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
");
  
db_res(" 
CREATE TABLE IF NOT EXISTS `modzzz_location_service_cmts_track` (
  `cmt_system_id` int( 11 ) NOT NULL default '0',
  `cmt_id` int( 11 ) NOT NULL default '0',
  `cmt_rate` tinyint( 4 ) NOT NULL default '0',
  `cmt_rate_author_id` int( 10 ) unsigned NOT NULL default '0',
  `cmt_rate_author_nip` int( 11 ) unsigned NOT NULL default '0',
  `cmt_rate_ts` int( 11 ) NOT NULL default '0',
  PRIMARY KEY (`cmt_system_id` , `cmt_id` , `cmt_rate_author_nip`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
");
  
db_res(" 
CREATE TABLE IF NOT EXISTS `modzzz_location_service_views_tk` (
  `id` int(10) unsigned NOT NULL,
  `viewer` int(10) unsigned NOT NULL,
  `ip` int(10) unsigned NOT NULL,
  `ts` int(10) unsigned NOT NULL,
  KEY `id` (`id`,`viewer`,`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
  
db_res("
INSERT INTO `sys_pre_values` ( `Key`, `Value`, `Order`, `LKey`) VALUES 
('LocationService', 1, 1, '__modzzz_location_service_business'), 
('LocationService', 2, 2, '__modzzz_location_service_community'),
('LocationService', 3, 3, '__modzzz_location_service_education'),
('LocationService', 4, 4, '__modzzz_location_service_government'),
('LocationService', 5, 5, '__modzzz_location_service_legal'),
('LocationService', 6, 6, '__modzzz_location_service_medical'),
('LocationService', 7, 7, '__modzzz_location_service_recreation'),
('LocationService', 8, 8, '__modzzz_location_service_religion'),
('LocationService', 9, 9, '__modzzz_location_service_other');
");
  
db_res("
INSERT INTO `sys_objects_vote` VALUES (NULL, 'modzzz_location_service', 'modzzz_location_service_rating', 'modzzz_location_service_rating_track', 'gal_', '5', 'vote_send_result', 'BX_PERIOD_PER_VOTE', '1', '', '', 'modzzz_location_service_main', 'rate', 'rate_count', 'id', 'BxLocationServiceVoting', 'modules/modzzz/location/classes/BxLocationServiceVoting.php');
");
  
db_res("
INSERT INTO `sys_objects_cmts` VALUES (NULL, 'modzzz_location_service', 'modzzz_location_service_cmts', 'modzzz_location_service_cmts_track', '0', '1', '90', '5', '1', '-3', 'slide', '2000', '1', '1', 'cmt', 'modzzz_location_service_main', 'id', 'comments_count', 'BxLocationServiceCmts', 'modules/modzzz/location/classes/BxLocationServiceCmts.php');
");
  
db_res("
INSERT INTO `sys_objects_views` VALUES(NULL, 'modzzz_location_service', 'modzzz_location_service_views_tk', 86400, 'modzzz_location_service_main', 'id', 'views', 1);
");
  
db_res("
INSERT INTO `sys_objects_actions` (`Caption`, `Icon`, `Url`, `Script`, `Eval`, `Order`, `Type`) VALUES 
    ('{TitleEdit}', 'modules/modzzz/location/|edit.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return  BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''service/edit/{ID}'';', '0', 'modzzz_location_service'),
    ('{TitleDelete}', 'modules/modzzz/location/|action_block.png', '', 'getHtmlData( ''ajaxy_popup_result_div_{ID}'', ''{evalResult}'', false, ''post'');return false;', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return  BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''service/delete/{ID}'';', '1', 'modzzz_location_service');
");
   

$iMaxOrder = (int)db_value("SELECT `Order` FROM `sys_page_compose_pages` ORDER BY `Order` DESC LIMIT 1");
$iMaxOrder++;

db_res("
INSERT INTO `sys_page_compose_pages` (`Name`, `Title`, `Order`) VALUES ('modzzz_location_services_view', 'Location Service View', $iMaxOrder);
");
 

$iMaxOrder++;
db_res("
INSERT INTO `sys_page_compose_pages` (`Name`, `Title`, `Order`) VALUES ('modzzz_location_services_browse', 'Location Service Browse', $iMaxOrder);
");
  
db_res("
INSERT INTO `sys_page_compose` (`Page`, `PageWidth`, `Desc`, `Caption`, `Column`, `Order`, `Func`, `Content`, `DesignBox`, `ColWidth`, `Visible`, `MinWidth`) VALUES 
    
    ('modzzz_location_services_browse', '998px', 'Location Service''s browse block', '_modzzz_location_block_browse_services', '1', '0', 'Browse', '', '1', '100', 'non,memb', '0'),

    ('modzzz_location_services_view', '998px', 'Location Service''s actions block', '_modzzz_location_block_actions', '1', '0', 'Actions', '', '1', '34', 'non,memb', '0'),
    ('modzzz_location_services_view', '998px', 'Location Service''s rate block', '_modzzz_location_block_rate', '1', '1', 'Rate', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_services_view', '998px', 'Location Service''s info block', '_modzzz_location_block_info', '1', '2', 'Info', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_services_view', '998px', 'Location Service''s description block', '_modzzz_location_block_desc', '2', '0', 'Desc', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_services_view', '998px', 'Location Service''s photos block', '_modzzz_location_block_photos', '2', '1', 'Photos', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_services_view', '998px', 'Location Service''s videos block', '_modzzz_location_block_videos', '2', '2', 'Videos', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_services_view', '998px', 'Location Service''s sounds block', '_modzzz_location_block_sounds', '2', '3', 'Sounds', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_services_view', '998px', 'Location Service''s files block', '_modzzz_location_block_files', '2', '4', 'Files', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_services_view', '998px', 'Location Service''s comments block', '_modzzz_location_block_comments', '2', '5', 'Comments', '', '1', '66', 'non,memb', '0');    
 
");
  



// --- --------SCHOOL -----------------------------

db_res("  
CREATE TABLE IF NOT EXISTS `modzzz_location_school_main` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `location_id` int(11) NOT NULL,
  `title` varchar(100) NOT NULL default '',
  `uri` varchar(255) NOT NULL,
  `desc` text NOT NULL,
  `status` enum('approved','pending') NOT NULL default 'approved',
  `country` varchar(2) NOT NULL default 'US',
  `city` varchar(50) NOT NULL default '', 
  `address1` varchar(100) NOT NULL default '',
  `address2` varchar(100) NOT NULL default '',
  `zip` varchar(30) NOT NULL default '',   
  `located` varchar(100) NOT NULL default '', 
  `phone` varchar(100) NOT NULL default '',  
  `website` varchar(100) NOT NULL default '',  
  `thumb` int(11) NOT NULL,
  `photo` int(11) NOT NULL,
  `video_embed` TEXT NOT NULL,
  `created` int(11) NOT NULL, 
  `author_id` int(10) unsigned NOT NULL default '0',
  `tags` varchar(255) NOT NULL default '',
  `categories` text NOT NULL,
  `views` int(11) NOT NULL,
  `rate` float NOT NULL,
  `rate_count` int(11) NOT NULL,
  `fans_count` int(11) NOT NULL,
  `comments_count` int(11) NOT NULL,
  `featured` tinyint(4) NOT NULL,
  `allow_view_to` int(11) NOT NULL,
  `allow_view_participants_to` varchar(16) NOT NULL,
  `allow_comment_to` varchar(16) NOT NULL,
  `allow_rate_to` varchar(16) NOT NULL,
  `allow_join_to` int(11) NOT NULL,
  `allow_post_in_forum_to` varchar(16) NOT NULL,
  `join_confirmation` tinyint(4) NOT NULL default '0',
  `allow_upload_photos_to` varchar(16) NOT NULL,
  `allow_upload_videos_to` varchar(16) NOT NULL,
  `allow_upload_sounds_to` varchar(16) NOT NULL,
  `allow_upload_files_to` varchar(16) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `loc_school_uri` (`uri`),
  KEY `loc_school_author_id` (`author_id`),
  KEY `loc_school_created` (`created`),
  FULLTEXT KEY `loc_school_title` (`title`,`desc`,`city`,`tags`,`categories`),
  FULLTEXT KEY `loc_school_tags` (`tags`),
  FULLTEXT KEY `loc_school_categories` (`categories`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
");
  
db_res("  
CREATE TABLE IF NOT EXISTS `modzzz_location_school_images` (
  `entry_id` int(10) unsigned NOT NULL,
  `media_id` int(10) unsigned NOT NULL,
  UNIQUE KEY `entry_id` (`entry_id`,`media_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
  
db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_school_videos` (
  `entry_id` int(10) unsigned NOT NULL,
  `media_id` int(11) NOT NULL,
  UNIQUE KEY `entry_id` (`entry_id`,`media_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
  
db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_school_sounds` (
  `entry_id` int(10) unsigned NOT NULL,
  `media_id` int(11) NOT NULL,
  UNIQUE KEY `entry_id` (`entry_id`,`media_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
  
db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_school_files` (
  `entry_id` int(10) unsigned NOT NULL,
  `media_id` int(11) NOT NULL,
  UNIQUE KEY `entry_id` (`entry_id`,`media_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
  
db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_school_rating` (
  `gal_id` smallint( 6 ) NOT NULL default '0',
  `gal_rating_count` int( 11 ) NOT NULL default '0',
  `gal_rating_sum` int( 11 ) NOT NULL default '0',
  UNIQUE KEY `gal_id` (`gal_id`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
");
  
db_res(" 
CREATE TABLE IF NOT EXISTS `modzzz_location_school_rating_track` (
  `gal_id` smallint( 6 ) NOT NULL default '0',
  `gal_ip` varchar( 20 ) default NULL,
  `gal_date` datetime default NULL,
  KEY `gal_ip` (`gal_ip`, `gal_id`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
");
  
db_res(" 
CREATE TABLE IF NOT EXISTS `modzzz_location_school_cmts` (
  `cmt_id` int( 11 ) NOT NULL AUTO_INCREMENT ,
  `cmt_parent_id` int( 11 ) NOT NULL default '0',
  `cmt_object_id` int( 12 ) NOT NULL default '0',
  `cmt_author_id` int( 10 ) unsigned NOT NULL default '0',
  `cmt_text` text NOT NULL ,
  `cmt_mood` tinyint( 4 ) NOT NULL default '0',
  `cmt_rate` int( 11 ) NOT NULL default '0',
  `cmt_rate_count` int( 11 ) NOT NULL default '0',
  `cmt_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `cmt_replies` int( 11 ) NOT NULL default '0',
  PRIMARY KEY ( `cmt_id` ),
  KEY `cmt_object_id` (`cmt_object_id` , `cmt_parent_id`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
");
  
db_res(" 
CREATE TABLE IF NOT EXISTS `modzzz_location_school_cmts_track` (
  `cmt_system_id` int( 11 ) NOT NULL default '0',
  `cmt_id` int( 11 ) NOT NULL default '0',
  `cmt_rate` tinyint( 4 ) NOT NULL default '0',
  `cmt_rate_author_id` int( 10 ) unsigned NOT NULL default '0',
  `cmt_rate_author_nip` int( 11 ) unsigned NOT NULL default '0',
  `cmt_rate_ts` int( 11 ) NOT NULL default '0',
  PRIMARY KEY (`cmt_system_id` , `cmt_id` , `cmt_rate_author_nip`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
");
  
db_res(" 
CREATE TABLE IF NOT EXISTS `modzzz_location_school_views_tk` (
  `id` int(10) unsigned NOT NULL,
  `viewer` int(10) unsigned NOT NULL,
  `ip` int(10) unsigned NOT NULL,
  `ts` int(10) unsigned NOT NULL,
  KEY `id` (`id`,`viewer`,`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
  
db_res("
INSERT INTO `sys_pre_values` ( `Key`, `Value`, `Order`, `LKey`) VALUES 
('LocationSchool', 1, 1, '__modzzz_location_school_elementary'),
('LocationSchool', 2, 2, '__modzzz_location_school_primary'),
('LocationSchool', 3, 3, '__modzzz_location_school_prep'),
('LocationSchool', 4, 4, '__modzzz_location_school_secondary'),
('LocationSchool', 5, 5, '__modzzz_location_school_high'),
('LocationSchool', 6, 6, '__modzzz_location_school_community College'),
('LocationSchool', 7, 7, '__modzzz_location_school_technical'),
('LocationSchool', 8, 8, '__modzzz_location_school_college'),
('LocationSchool', 9, 9, '__modzzz_location_school_university'),
('LocationSchool', 10, 10, '__modzzz_location_school_other');
");
  
db_res("
INSERT INTO `sys_objects_vote` VALUES (NULL, 'modzzz_location_school', 'modzzz_location_school_rating', 'modzzz_location_school_rating_track', 'gal_', '5', 'vote_send_result', 'BX_PERIOD_PER_VOTE', '1', '', '', 'modzzz_location_school_main', 'rate', 'rate_count', 'id', 'BxLocationSchoolVoting', 'modules/modzzz/location/classes/BxLocationSchoolVoting.php');
");
  
db_res("
INSERT INTO `sys_objects_cmts` VALUES (NULL, 'modzzz_location_school', 'modzzz_location_school_cmts', 'modzzz_location_school_cmts_track', '0', '1', '90', '5', '1', '-3', 'slide', '2000', '1', '1', 'cmt', 'modzzz_location_school_main', 'id', 'comments_count', 'BxLocationSchoolCmts', 'modules/modzzz/location/classes/BxLocationSchoolCmts.php');
");
  
db_res("
INSERT INTO `sys_objects_views` VALUES(NULL, 'modzzz_location_school', 'modzzz_location_school_views_tk', 86400, 'modzzz_location_school_main', 'id', 'views', 1);
");
 
  
db_res("
INSERT INTO `sys_objects_actions` (`Caption`, `Icon`, `Url`, `Script`, `Eval`, `Order`, `Type`) VALUES 
    ('{TitleEdit}', 'modules/modzzz/location/|edit.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return  BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''school/edit/{ID}'';', '0', 'modzzz_location_school'),
    ('{TitleDelete}', 'modules/modzzz/location/|action_block.png', '', 'getHtmlData( ''ajaxy_popup_result_div_{ID}'', ''{evalResult}'', false, ''post'');return false;', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return  BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''school/delete/{ID}'';', '1', 'modzzz_location_school');
");
 

$iMaxOrder = (int)db_value("SELECT `Order` FROM `sys_page_compose_pages` ORDER BY `Order` DESC LIMIT 1");
$iMaxOrder++;
    
 db_res("
INSERT INTO `sys_page_compose_pages` (`Name`, `Title`, `Order`) VALUES ('modzzz_location_schools_view', 'Location School View', $iMaxOrder);
");
 
$iMaxOrder++;
  
db_res("
INSERT INTO `sys_page_compose_pages` (`Name`, `Title`, `Order`) VALUES ('modzzz_location_schools_browse', 'Location School Browse', $iMaxOrder);
");
  
db_res("
INSERT INTO `sys_page_compose` (`Page`, `PageWidth`, `Desc`, `Caption`, `Column`, `Order`, `Func`, `Content`, `DesignBox`, `ColWidth`, `Visible`, `MinWidth`) VALUES 
    
    ('modzzz_location_schools_browse', '998px', 'Location School''s browse block', '_modzzz_location_block_browse_schools', '1', '0', 'Browse', '', '1', '100', 'non,memb', '0'),
 
    ('modzzz_location_schools_view', '998px', 'Location School''s actions block', '_modzzz_location_block_actions', '1', '0', 'Actions', '', '1', '34', 'non,memb', '0'),
    ('modzzz_location_schools_view', '998px', 'Location School''s rate block', '_modzzz_location_block_rate', '1', '1', 'Rate', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_schools_view', '998px', 'Location School''s info block', '_modzzz_location_block_info', '1', '2', 'Info', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_schools_view', '998px', 'Location School''s description block', '_modzzz_location_block_desc', '2', '0', 'Desc', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_schools_view', '998px', 'Location School''s photos block', '_modzzz_location_block_photos', '2', '1', 'Photos', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_schools_view', '998px', 'Location School''s videos block', '_modzzz_location_block_videos', '2', '2', 'Videos', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_schools_view', '998px', 'Location School''s sounds block', '_modzzz_location_block_sounds', '2', '3', 'Sounds', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_schools_view', '998px', 'Location School''s files block', '_modzzz_location_block_files', '2', '4', 'Files', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_schools_view', '998px', 'Location School''s comments block', '_modzzz_location_block_comments', '2', '5', 'Comments', '', '1', '66', 'non,memb', '0');    
");
  
db_res("
INSERT INTO `sys_page_compose` (`Page`, `PageWidth`, `Desc`, `Caption`, `Column`, `Order`, `Func`, `Content`, `DesignBox`, `ColWidth`, `Visible`, `MinWidth`) VALUES 
 
    ('modzzz_location_nightlifes_view', '998px', 'Location Nightlife''s deals block', '_modzzz_location_block_deals', '2', '2', 'Deals', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_nightlifes_view', '998px', 'Location Nightlife''s specials block', '_modzzz_location_block_specials', '2', '3', 'Specials', '', '1', '34', 'non,memb', '0'),    

    ('modzzz_location_foods_view', '998px', 'Location Food''s deals block', '_modzzz_location_block_deals', '2', '2', 'Deals', '', '1', '66', 'non,memb', '0'),
    ('modzzz_location_foods_view', '998px', 'Location Food''s specials block', '_modzzz_location_block_specials', '2', '3', 'Specials', '', '1', '34', 'non,memb', '0'),    
 

    ('modzzz_location_events_view', '998px', 'Location Event''s Video Embed block', '_modzzz_location_block_video_embed', '2', '3', 'VideoEmbed', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_nightlifes_view', '998px', 'Location Nightlife''s Video Embed block', '_modzzz_location_block_video_embed', '2', '5', 'VideoEmbed', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_hotels_view', '998px', 'Location Hotel''s Video Embed block', '_modzzz_location_block_video_embed', '2', '3', 'VideoEmbed', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_foods_view', '998px', 'Location Food''s Video Embed block', '_modzzz_location_block_video_embed', '2', '5', 'VideoEmbed', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_transports_view', '998px', 'Location Transport''s Video Embed block', '_modzzz_location_block_video_embed', '2', '3', 'VideoEmbed', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_shops_view', '998px', 'Location Shop''s Video Embed block', '_modzzz_location_block_video_embed', '2', '3', 'VideoEmbed', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_schools_view', '998px', 'Location School''s Video Embed block', '_modzzz_location_block_video_embed', '2', '3', 'VideoEmbed', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_services_view', '998px', 'Location Service''s google map block', '_modzzz_location_block_map', '1', '1', 'Logo', '', '1', '34', 'non,memb', '0'),   
 
    ('modzzz_location_events_view', '998px', 'Location Event''s google map block', '_modzzz_location_block_map', '2', '1', 'Map', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_nightlifes_view', '998px', 'Location Nightlife''s google map block', '_modzzz_location_block_map', '2', '1', 'Map', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_hotels_view', '998px', 'Location Hotel''s google map block', '_modzzz_location_block_map', '2', '1', 'Map', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_foods_view', '998px', 'Location Food''s google map block', '_modzzz_location_block_map', '2', '1', 'Map', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_transports_view', '998px', 'Location Transport''s google map block', '_modzzz_location_block_map', '2', '1', 'Map', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_shops_view', '998px', 'Location Shop''s google map block', '_modzzz_location_block_map', '2', '1', 'Map', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_schools_view', '998px', 'Location School''s google map block', '_modzzz_location_block_map', '2', '1', 'Map', '', '1', '66', 'non,memb', '0'),   
    ('modzzz_location_services_view', '998px', 'Location Service''s google map block', '_modzzz_location_block_map', '1', '1', 'Logo', '', '1', '34', 'non,memb', '0'),   
 
    ('modzzz_location_events_view', '998px', 'Location Event''s logo block', '_modzzz_location_block_logo', '1', '1', 'Logo', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_nightlifes_view', '998px', 'Location Nightlife''s logo block', '_modzzz_location_block_logo', '1', '1', 'Logo', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_hotels_view', '998px', 'Location Hotel''s logo block', '_modzzz_location_block_logo', '1', '1', 'Logo', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_foods_view', '998px', 'Location Food''s logo block', '_modzzz_location_block_logo', '1', '1', 'Logo', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_transports_view', '998px', 'Location Transport''s logo block', '_modzzz_location_block_logo', '1', '1', 'Logo', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_shops_view', '998px', 'Location Shop''s logo block', '_modzzz_location_block_logo', '1', '1', 'Logo', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_schools_view', '998px', 'Location School''s logo block', '_modzzz_location_block_logo', '1', '1', 'Logo', '', '1', '34', 'non,memb', '0'),    
    ('modzzz_location_services_view', '998px', 'Location Service''s logo block', '_modzzz_location_block_logo', '1', '1', 'Logo', '', '1', '34', 'non,memb', '0')   

");


db_res("
CREATE TABLE IF NOT EXISTS `modzzz_location_deals` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `id_entry` int(10) unsigned NOT NULL,
  `type` varchar(100) NOT NULL,  
  `name` varchar(100) NOT NULL,  
  `count` varchar(100) NOT NULL,  
  `start_date` int(10) unsigned NOT NULL,
  `end_date` int(10) unsigned NOT NULL, 
  `price` float NOT NULL,   
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;  
");
 
db_res("
INSERT INTO `sys_cron_jobs` ( `name`, `time`, `class`, `file`, `eval`) VALUES
 ( 'BxLocation', '*/1 * * * *', 'BxLocationCron', 'modules/modzzz/location/classes/BxLocationCron.php', '') ;
");

$iCategId = (int)db_value("SELECT `id` FROM  `sys_options_cats` WHERE `name`='Location'");
db_res("  
INSERT INTO `sys_options` (`Name`, `VALUE`, `kateg`, `desc`, `Type`, `check`, `err_text`, `order_in_kateg`, `AvailableValues`) VALUES  
('modzzz_location_map_zoom', '4', $iCategId, 'default zoom for google map on main location page', 'digit', '', '', '0', ''), 
('modzzz_location_map_lat', '40', $iCategId, 'default latitude for google map on main location page', 'digit', '', '', '0', ''), 
('modzzz_location_map_long', '-100', $iCategId, 'default longitude for google map on main location page', 'digit', '', '', '0', ''),
('modzzz_location_map_default_distance', '50', $iCategId, 'default distance for google map proximity search', 'digit', '', '', '0', '')   
");


db_res("
INSERT INTO `sys_objects_actions` (`Caption`, `Icon`, `Url`, `Script`, `Eval`, `Order`, `Type`) VALUES 
    ('{TitleServiceAdd}', 'modules/modzzz/location/|action_add_service.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''service/add/{ID}'';', '20', 'modzzz_location'), 
    ('{TitleSchoolAdd}', 'modules/modzzz/location/|action_add_school.png', '{evalResult}', '', '\$oConfig = \$GLOBALS[''oBxLocationModule'']->_oConfig; return BX_DOL_URL_ROOT . \$oConfig->getBaseUri() . ''school/add/{ID}'';', '21', 'modzzz_location')  

");

 
db_res("
UPDATE `sys_menu_top` SET `Link` = CONCAT(`Link`, '|modules/?r=location/school/add/|modules/?r=location/school/edit/|modules/?r=location/school/view/|modules/?r=location/school/browse/|modules/?r=location/service/add/|modules/?r=location/service/edit/|modules/?r=location/service/view/|modules/?r=location/service/browse/')  WHERE `Name`='Location' AND `Caption`='_modzzz_location_menu_root' AND  `Type` ='system' 
");
 
db_res("ALTER TABLE `modzzz_location_nightlife_main`
  ADD `zip` varchar(30) NOT NULL default '',   
  ADD `video_embed` TEXT NOT NULL ,
  ADD `cover_charge` varchar(100) NOT NULL default '',   
  ADD `specials` text NOT NULL,
  ADD `hh_specials` text NOT NULL,
  ADD `discounts` text NOT NULL,
  ADD `vip_info` text NOT NULL, 
  ADD `signature_drink` varchar(100) NOT NULL default '', 
  ADD `signature_food` varchar(100) NOT NULL default '', 
  ADD `photo` int(11) NOT NULL  
");

db_res("ALTER TABLE `modzzz_location_event_main`
ADD `zip` varchar(30) NOT NULL default '',   
ADD `video_embed` TEXT NOT NULL, 
ADD `photo` int(11) NOT NULL ,
ADD `address1` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '',
ADD `address2` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default ''
");

db_res("UPDATE `modzzz_location_event_main` SET `address1` = `place`");
  
db_res("ALTER TABLE `modzzz_location_transport_main`
ADD `zip` varchar(30) NOT NULL default '',   
ADD `video_embed` TEXT NOT NULL, 
ADD `photo` int(11) NOT NULL 
");

db_res("ALTER TABLE `modzzz_location_hotel_main`
ADD `zip` varchar(30) NOT NULL default '',   
ADD `video_embed` TEXT NOT NULL, 
ADD `photo` int(11) NOT NULL 
");

db_res("ALTER TABLE `modzzz_location_shop_main`
ADD `zip` varchar(30) NOT NULL default '',   
ADD `video_embed` TEXT NOT NULL, 
ADD `photo` int(11) NOT NULL 
");

db_res("ALTER TABLE `modzzz_location_food_main` 
ADD `zip` varchar(30) NOT NULL default '',   
ADD `video_embed` TEXT NOT NULL, 
ADD `photo` int(11) NOT NULL, 
ADD `cover_charge` varchar(100) NOT NULL default '',   
ADD `specials` text NOT NULL,
ADD `hh_specials` text NOT NULL,
ADD `discounts` text NOT NULL,
ADD `vip_info` text NOT NULL, 
ADD `signature_drink` varchar(100) NOT NULL default '', 
ADD `signature_food` varchar(100) NOT NULL default '' 
");

db_res(" 
CREATE TABLE IF NOT EXISTS `modzzz_location_sub_profiles` (
  `id` int(10) unsigned NOT NULL,
  `subtype` varchar(30) NOT NULL,
  `author_id` int(10) unsigned NOT NULL default '0',  
  `ts` int(10) unsigned NOT NULL,
  `lat` double NOT NULL,
  `lng` double NOT NULL,
  `zoom` tinyint(4) NOT NULL default '-1',  
  `type` char(16) NOT NULL,
  `address` varchar(255) NOT NULL,
  `country` varchar(2) NOT NULL,
  `allow_view_location_to` int(11) NOT NULL default '3',
  `failed` tinyint(4) NOT NULL,
  PRIMARY KEY  (`id`, `subtype`),
  KEY `sub_lat` (`lat`),
  KEY `sub_lng` (`lng`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
");
 

$iCatId = (int)db_value("
SELECT `id` FROM  `sys_menu_top` WHERE `Name`='Location' AND `Caption`='_modzzz_location_menu_root' AND  `Type` ='system' 
");
 
db_res("
INSERT INTO `sys_menu_top` (`ID`, `Parent`, `Name`, `Caption`, `Link`, `Order`, `Visible`, `Target`, `Onclick`, `Check`, `Editable`, `Deletable`, `Active`, `Type`, `Picture`, `Icon`, `BQuickLink`, `Statistics`) VALUES (NULL, $iCatId, 'Location View Schools', '_modzzz_location_menu_view_schools', 'modules/?r=location/school/browse/{modzzz_location_view_uri}', 5, 'non,memb', '', '', '', 1, 1, 1, 'custom', 'modules/modzzz/location/|modzzz_location.png', '', 0, '');
");

 
db_res("
INSERT INTO `sys_menu_top` (`ID`, `Parent`, `Name`, `Caption`, `Link`, `Order`, `Visible`, `Target`, `Onclick`, `Check`, `Editable`, `Deletable`, `Active`, `Type`, `Picture`, `Icon`, `BQuickLink`, `Statistics`) VALUES (NULL, $iCatId, 'Location View Services', '_modzzz_location_menu_view_services', 'modules/?r=location/service/browse/{modzzz_location_view_uri}', 5, 'non,memb', '', '', '', 1, 1, 1, 'custom', 'modules/modzzz/location/|modzzz_location.png', '', 0, '');
");




echo "SUCCESSFULLY UPDATED DATABASE ..... <br /><br />";
 

echo "FINISHED <br />";


?>